package com.cy.sys.shiro;

import java.time.LocalDateTime;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

import com.cy.sys.log.service.exception.ServiceException;

public class TimeAccessIntercptor implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		System.out.println("==拦截-=-==");
		LocalDateTime now = LocalDateTime.now();	//jdk-8获取时间日期的新语法
		int end = now.getHour();	//获取当前值
		if(end>9&&end<22)
			return true;
		 throw new ServiceException("请在规定时间类访问9~15");// true 放行, false终止
	}
	
}
